package com.cloudpivot.project.crmprojectnew.controller;

import com.cloudpivot.project.crmprojectnew.pojo.ResultJson;
import com.cloudpivot.project.crmprojectnew.pojo.accountequipment.AccountEquipment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;

/**
 * 测试接口
 */
@Controller
@Slf4j
@RequestMapping("/crmTest")
public class TestController {


    /**
     * 获取客户设备记录(单条)
     */
    @PostMapping("testinterface")
    @ResponseBody
    public AccountEquipment testinterface(@RequestBody Object obj){
        log.info(obj.toString());
       return null;
    }

    @ResponseBody
    @ExceptionHandler(MethodArgumentNotValidException.class)
    public ResultJson exceptionHandler(MethodArgumentNotValidException e) {
        ResultJson resultJson = new ResultJson(-1, "error");
        resultJson.setMsg(e.getBindingResult().getFieldError().getDefaultMessage());
        return resultJson;
    }
}
